package homework.qq;

import java.util.*;

/**
 * HashSet set = new HashSet();
 * 	Iterator iter = list.listIterator();
 * 	while(iter.hasNext()){
 * 		String str = (String)iter.next();
 * 		if(!set.contains(str))
 * 			set.add(str);
 * 		else
 * 			iter.remove();
 *
 *
 *
 */
public class QQ {

    public static void main(String[] args) {
        String[] strs = {"12345","67891","12347809933","98765432102","67891","12347809933"};
        List<String> list = new LinkedList<>();

        for (String str : strs) {
            list.add(str);
        }
        System.out.println("去重前："+list);
        System.out.println("-----------------------------");
        LinkedHashSet<String> lset = new LinkedHashSet<>();
        lset.addAll(list);
        list.clear();
        list.addAll(lset);

        Iterator<String> it = list.listIterator();
        while (it.hasNext()){
            String str = it.next();
            System.out.println(str);
        }
        System.out.println("-----------------------------");

        for (String sts : list) {
            System.out.println(sts);
        }
        System.out.println("-----------------------------");
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一串字符:");
        String str = sc.nextLine();

        System.out.println("去重前");
        System.out.print(str+"\n");

        char[] chars = str.toCharArray();
        LinkedHashSet<Character> listset  = new LinkedHashSet<>();
        for (char c : chars) {
            listset.add(c);
        }


        Iterator<Character> item = listset.iterator();
        System.out.println("去重后");
        while (item.hasNext()){
            System.out.print(item.next()+"\t");
        }
    }
}
